<template>
<img :src="bg" style="position: absolute;z-index: 0;width: 100vw;height: 100vh;"/>
	<p class="title">请选择你的角色</p>
	<div class="roles">
		<div class="item animate__animated" @click="select('father')" :class="[selectIndex === 0 ? 'animate__pulse' : '', firstLoad ? 'animate__rotateInDownLeft' : '']">
			<img :src="fatherUrl" />
			<div class="btn">选&nbsp;择</div>
		</div>
		<div class="item animate__animated" @click="select('monther')" :class="[selectIndex === 1 ? 'animate__pulse' : '', firstLoad ? 'animate__rotateInUpRight' : '']">
			<img :src="montherUrl" />
			<div class="btn">选&nbsp;择</div>
		</div>
	</div>
</template>
<script setup>
import { ref } from "vue";
const emits=defineEmits(['chooseRole'])
const bg='./img/bg.jpg'
const fatherUrl = "./img/父亲.jpg";
const montherUrl = "./img/母亲.jpg";
const firstLoad = ref(true);
const selectIndex = ref(-1);
const select = (val) => {
	firstLoad.value = false;
	selectIndex.value = val === "father" ? 0 : 1;
  setTimeout(() => {
      emits('chooseRole',val)
  }, 800);
};
</script>
<style scoped>
.roles {
	display: flex;
	justify-content: space-evenly;
	align-items: center;
	width: 100%;
}
.roles .item {
	width: 22vw;
	text-align: center;
	transition: all 1s;
}
.roles .item img {
	width: 100%;
}
.title {
	text-align: center;
	font-size: 1.7rem;
	font-weight: bolder;
	color: transparent;
	-webkit-text-fill-color: #ffffff;
	-webkit-text-stroke: 1px #f1b6b4;
	margin: 5vh 0;
}
.roles .item .btn {
	padding: 0.8vw 5vw;
	border: 2px solid #f1b6b4;
	border-radius: 2px;
	color: transparent;
	-webkit-text-fill-color: #ffffff;
	-webkit-text-stroke: 1px #f1b6b4;
	display: flex;
	justify-content: center;
	align-items: center;
	font-size: 1.5rem;
	box-shadow: 3px 2px 4px 0px #f1b6b4b8;
	display: inline;
	user-select: none;
}
</style>
